<!-- 购苗木会员权益 -->
<template>
  <div class="vip_rights">
    <!-- 顶部导航 -->
    <van-nav-bar
      title="购苗木会员权益"
      left-arrow
      @click-left="onClickLeft"
      fixed
      placeholder
      safe-area-inset-top
    />

    <!-- 内容区域 -->
    <div class="content-wrapper">
      <!-- 绿色背景的横向滚动图标区域 -->
      <div class="icons-header">
        <div class="icons-scroll">
          <div
            v-for="(item, index) in iconList"
            :key="index"
            class="icon-item"
            @click="handleIconClick(index)"
          >
            <div class="icon-circle">
              <img class="icon-img" :src="getAssetsFile(index, activeIndex)" :alt="item.title" />
            </div>
            <p class="icon-label">{{ item.title }}</p>
          </div>
        </div>
      </div>

      <!-- 主要内容区域 -->
      <div class="main-content">
        <div v-for="(item, index) in iconList" :key="index">
          <div v-show="index === activeIndex">
            <div class="section-title">
              <div class="title-bar"></div>
              <h2 class="title-text">{{ item.title }}</h2>
            </div>

            <!-- 什么是苗币 -->
            <div
              class="content-section"
              v-for="(subItem, subIndex) in item.contentList"
              :key="subIndex"
            >
              <div class="section-header">
                <van-icon name="play" class="play-icon" />
                <h3 class="section-title-text">{{ subItem.title }}</h3>
              </div>
              <div class="section-content">
                <p class="content-text" v-html="subItem.desc"></p>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 底部按钮区域 -->
      <div class="footer-buttons">
        <div class="info-button">
          <span>仅白金及以上等级会员享此权益</span>
        </div>
        <van-button class="activate-button" round block @click="handleActivate">
          立即开通
        </van-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import bridge from '@/utils/bridge'
import { getAssetsFile, iconList } from '@/staticData'

const router = useRouter()
const activeIndex = ref(0)
const handleIconClick = (index) => {
  activeIndex.value = index
}

const handleActivate = () => {
  router.push({
    path: '/vip'
  })
}

const onClickLeft = () => {
  bridge.closeWebView()
}

onMounted(async () => {
  bridge.setNavigationBarVisible({
    value: '0'
  })
})
</script>

<style lang="scss" scoped>
.vip_rights {
  min-height: 100vh;
  background: #fff;

  :deep(.van-nav-bar) {
    &::after {
      border: none;
    }

    .van-icon {
      color: #222;
    }

    .van-nav-bar__title {
      font-size: 17px;
      font-weight: normal;
      color: #222;
    }
  }

  .content-wrapper {
    padding-bottom: 100px;
  }

  // 绿色背景的横向滚动图标区域
  .icons-header {
    background: #53d4ac;
    padding: 10px 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;

    &::-webkit-scrollbar {
      display: none;
    }

    .icons-scroll {
      display: flex;
      align-items: center;
      padding: 0 16px;
      gap: 24px;
      min-width: max-content;

      .icon-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        flex-shrink: 0;
        cursor: pointer;

        .icon-circle {
          width: 40px;
          height: 40px;
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
          margin-bottom: 8px;
          transition: all 0.3s;

          &:active {
            transform: scale(0.95);
          }

          .icon-img {
            width: 32px;
            height: 32px;
            object-fit: contain;
          }
        }

        .icon-label {
          font-size: 11px;
          color: #fff;
          margin: 0;
          text-align: center;
          white-space: nowrap;
        }
      }
    }
  }

  // 主要内容区域
  .main-content {
    padding: 20px 16px;

    // 赠送苗币标题
    .section-title {
      display: flex;
      align-items: center;
      margin-bottom: 20px;

      .title-bar {
        width: 4px;
        height: 18px;
        background: #32bc05;
        border-radius: 2px;
        margin-right: 8px;
      }

      .title-text {
        font-size: 18px;
        font-weight: 600;
        color: #222;
        margin: 0;
      }
    }

    // 内容区块
    .content-section {
      margin-bottom: 24px;

      .section-header {
        display: flex;
        align-items: center;
        margin-bottom: 12px;

        .play-icon {
          color: #32bc05;
          font-size: 12px;
          margin-right: 6px;
        }

        .section-title-text {
          font-size: 16px;
          font-weight: 600;
          color: #222;
          margin: 0;
        }
      }

      .section-content {
        padding-left: 18px;

        .content-text {
          font-size: 14px;
          color: #666;
          line-height: 1.8;
          margin: 0 0 12px 0;

          &.highlight-text {
            margin-bottom: 8px;
          }

          &:last-child {
            margin-bottom: 0;
          }
        }

        // 使用场景
        .scenario-item {
          margin-bottom: 16px;
          padding: 12px;
          background: #f8f8f8;
          border-radius: 8px;

          &:last-child {
            margin-bottom: 0;
          }

          .scenario-title {
            font-size: 14px;
            font-weight: 500;
            color: #222;
            margin: 0 0 6px 0;
          }

          .scenario-desc {
            font-size: 13px;
            color: #32bc05;
            font-weight: 500;
            margin: 0 0 4px 0;
          }

          .scenario-benefit {
            font-size: 13px;
            color: #999;
            margin: 0;
          }
        }
      }
    }
  }

  // 底部按钮区域
  .footer-buttons {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 10;

    .info-button {
      background: #fff1e2;
      border-radius: 8px;
      padding: 10px 16px;
      margin-bottom: 12px;
      text-align: center;

      span {
        font-size: 13px;
        color: #222;
      }
    }

    .activate-button {
      background: #32bc05;
      border: none;
      height: 44px;
      font-size: 16px;
      font-weight: 500;
      color: #fff;

      &:active {
        background: #28a005;
      }
    }
  }
}
</style>
